capture program drop policyeffect

program policyeffect, rclass
	syntax varlist(min=3)  
	
	
	gettoken hab vlist:varlist
	gettoken gphiup vlist:vlist
	gettoken gphilow vlist:vlist

	tempname gphiabupper gphiablower
	gen `gphiabupper'=`hab'*(`hab'>=0)*`gphiup' + 	`hab'*(`hab'<0)*`gphilow'
	gen `gphiablower'=  `hab'*(`hab'<0)*`gphiup' + 	`hab'*(`hab'>=0)*`gphilow'
 
	quietly sum `gphiabupper'
	scalar phiu=r(mean)
	return scalar phiabupper = phiu
	quietly sum `gphiablower'
	scalar phil=r(mean)
	return scalar phiablower = phil
	
	dis " "
	dis in green "The effect of policy changes corresponding to the variable `hab' on phi lies in"
	dis in yellow "[" %5.3f phil ", " %5.3f phiu "]"
	dis " "

end


